package net.sapfree.display.tags;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

public class TestTag extends TagSupport {
	private int pageSize;//pageSize属性，控制页面显示的个数，并且要生成get和set方法

    public int getPageSize(){
        return pageSize;
    }

    public void setPageSize(int pageSize){
        this.pageSize = pageSize;
    }
    
	public int doStartTag() throws JspException{
        JspWriter out = pageContext.getOut();//用pageContext获取out，他还能获取session等，基本上jsp的内置对象都能获取，非常有用
        for (int i=0; i<pageSize; i++) {
            try{
                out.println("<table>");
                out.println("<tr>");
                out.println("<td>"); 
                out.println(i);
                out.println("</td>");
                out.println("<td>");
                out.println(i*10);
                out.println("</td>");
                out.println("</tr>");
                out.println("</table>");
            } catch (IOException e){
                e.printStackTrace();
            }
        }

        return SKIP_BODY;
    }

}
